﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KXmlUIControl
{
    public class XmlGroupObject
    {
        /// <summary>
        /// 组名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 控件组父窗体的名称
        /// </summary>
        public string Parent { get; set; }

        /// <summary>
        /// 默认选中的控件名称(可以包含多个控件)
        /// 如果包含多个控件，名称之间用';'分隔
        /// </summary>
        public string Default { get; set; }

        /// <summary>
        /// 组的深度
        /// </summary>
        public int Depth { get; set; }

        /// <summary>
        /// 包含子控件名称集合
        /// </summary>
        private List<XmlGroupMemberObject> listControls = new List<XmlGroupMemberObject>();

        public List<XmlGroupMemberObject> Controls
        {
            get { return listControls; }
        }

        public XmlGroupObject()
        {
            Depth = 0;
        }
        public void Add(XmlGroupMemberObject child)
        {
            if(listControls.FindIndex(r=>r.Name.Equals(child.Name)) >= 0)
            {
                throw new Exception("组对象不能添加重复的元素");
            }
            listControls.Add(child);
        }
    }
}
